//index.js

Page({
  data:{ 
        activity:true,
        full:null,
        decrease:null,
        indicatorDots : true,
        autoplay:true,
        interval:5000,
        duration:500,
    listData:[
      {
        imgUrls:[
          {
            id:1,
            title: '咖啡豆',
            url:'../../images/banner_1.png',
            link:11
          },
          {
            id:2,
            title: '蛋糕',
            url:'../../images/banner_2.png',
            link:12
          },
          {
            id:3,
            title: '冰咖啡',
            url:'../../images/banner_3.png',
            link: 13
          }
        ],
        imageAd:{
          id:4,
          title:'注册会员即赠送',
          url:'../../images/image_ad.png',
          link:14
        },
        imageBottom:[
          {
            id:5,
            title:'春日咖啡',
            url:'../../images/bottom_1.png',
            link:15
          },
          {
            id:6,
            title:'咖啡系列',
            url:'../../images/bottom_2.png',
            link:16
          },
          {
            id:7,
            title:'绿咖啡',
            url:'../../images/bottom_3.png',
            link:17
          },
          {
            id:8,
            title:'正能量咖啡',
            url:'../../images/bottom_4.png',
            link:18
          },
          {
            id:11,
            title:'春日咖啡',
            url:'../../images/bottom_1.png',
            link:15
          },
          {
            id:12,
            title:'咖啡系列',
            url:'../../images/bottom_2.png',
            link:16
          },
          {
            id:9,
            title:'绿咖啡',
            url:'../../images/bottom_3.png',
            link:17
          },
          {
            id:10,
            title:'正能量咖啡',
            url:'../../images/bottom_4.png',
            link:18
          }  
        ]
      }
    ]
  },
  onLoad:function(){
    var that = this;
    wx.request({
      url: 'http://localhost:8080/activity/all',
      method:"get",
      success:function(res){
        if(res.data.list!=null){
          var i = res.data.list.length-1;
          that.setData({
            full: res.data.list[i].full,
            decrease:res.data.list[i].decrease,
            activity:true
          })
        }else{
          that.setData({
            activity:false
          })
          
        }
        
      }
    })
  },
  onShow:function(){
    var that = this;
    wx.request({
      url: 'http://localhost:8080/activity/all',
      method:"get",
      success:function(res){
        if(res.data.list!=null){
          var i = res.data.list.length-1;
          that.setData({
            full: res.data.list[i].full,
            decrease:res.data.list[i].decrease
          })
        }else{
          that.setData({
            activity:false
          })
          
        }
        
      }
    })
    
  },
//开启点餐之旅，跳转到菜单列表页面
  gostart:function(){
     wx.navigateTo({
       url: '../list/list'
     })
  }
})
